package com.yinp.proapp.module.wanandroid.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.yinp.proapp.adapter.SingleViewHolder;
import com.yinp.proapp.bean.BannerEntity;
import com.yinp.proapp.databinding.ItemHomeBannerBinding;
import com.yinp.proapp.utils.GlideUtils;
import com.youth.banner.adapter.BannerAdapter;

import java.util.List;

public class WanHomeBannerAdapter extends BannerAdapter<BannerEntity, SingleViewHolder> {

    private final Context context;

    public WanHomeBannerAdapter(List<BannerEntity> datas, Context context) {
        super(datas);
        this.context = context;
    }

    @Override
    public SingleViewHolder onCreateHolder(ViewGroup parent, int viewType) {
        ItemHomeBannerBinding bannerBinding = ItemHomeBannerBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
        return new SingleViewHolder(bannerBinding);
    }

    @Override
    public void onBindView(SingleViewHolder holder, BannerEntity data, int position, int size) {
        BannerEntity entity = mDatas.get(position);
        ItemHomeBannerBinding binding = (ItemHomeBannerBinding) holder.getBinding();
        GlideUtils.loadUrl(context, binding.ivBanner, null, entity.getImagePath(), null, null, false, true);
    }
}
